function distance = crowding_distance1(chrom)
[N,Obj] = size(chrom);
M = Obj/2;

for i = 1:M
    f(i).interval =  chrom(:,2*i-1:2*i);         
    f(i).width = chrom(:,2*i) - chrom(:,2*i-1);  
    f(i).mid = mean(f(i).interval,2);            
end
shape = zeros(N,1);
for i = 1:N
    for g = 1:M-1
        for k = g+1:M
            shape(i) = abs(f(g).width(i)-f(k).width(i));
        end
    end
end
volume = ones(N,1);
for i = 1:N
    for g = 1:M
        volume(i) = volume(i)*f(g).width(i);
    end
end
vij = ones(N-1,1);
Dij = zeros(N-1,1);
sij = zeros(N-1,1);
for i = 1:N-1
    j = i + 1;
    for g = 1:M
        vij(i) =  vij(i) * jiaoji(f(g).interval(i,:),f(g).interval(j,:));
        sij(i) = sij(i) + abs(f(g).mid(i)-f(g).mid(j));
    end
    Dij(i) = sij(i)/(1+shape(i)+shape(j))/(vij(i)+volume(i)+volume(j)+1);
end
C = zeros(N,1);
C(1) = 0.5*Dij(1);
for i = 2:N-1
    C(i) = 0.5 * (Dij(i-1)+Dij(i));
end
C(N) = 0.5*Dij(N-1);
distance = C;
end